package com.two.service.restaurant.controller;

import com.two.common.util.CommonResult;
import com.two.common.vo.RestaurantVo;
import com.two.service.restaurant.service.RestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/restaurant/restaurant")
public class RestaurantController {

    @Autowired
    private RestaurantService restaurantService;

    //餐厅页面的初始化及模糊查询
    @RequestMapping("/selectAllByCondition")
    public CommonResult selectAllByCondition(Integer currentPage,Integer pageSize,@RequestBody RestaurantVo restaurantVo){
        return restaurantService.selectAllByCondition(currentPage,pageSize,restaurantVo);
    }

    //添加餐厅
    @PostMapping("/addRestaurant")
    public Integer addRestaurant(@RequestBody RestaurantVo restaurantVo){
        return restaurantService.addRestaurant(restaurantVo);
    }

    //修改餐厅
    @PostMapping("/updateRestaurant")
    public CommonResult updateRestaurant(@RequestBody RestaurantVo restaurantVo){
        return restaurantService.updateRestaurant(restaurantVo);
    }

    //删除餐厅
    @PostMapping("/deleteRestaurant")
    public CommonResult deleteRestaurant(@RequestBody RestaurantVo restaurantVo){
        return restaurantService.deleteRestaurant(restaurantVo);
    }

    //手机前端查询所有餐厅
    @PostMapping("/selectAllByRestaurantName")
    public CommonResult selectAllByRestaurantName(String restaurantName){
        return restaurantService.selectAllByRestaurantName(restaurantName);
    }

    //根据rid查询餐厅的详细信息
    @GetMapping("/selectByRid")
    public CommonResult selectByRid(String rid){
        Integer id = Integer.parseInt(rid);
        return restaurantService.selectByRid(id);

    }

}
